<?php
class ControllerNewsDetail extends Controller {
	
	public function index (){
		$this->load->model('news/news');
		$this->load->model('tool/seo_url'); 
		
		$News = array();
		if (isset($this->request->get['page'])) 
		{
			$page = $this->request->get['page'];
		} 
		else 
		{ 
			$page = 1;
		}	
		$limit = 5;
		$error = 0;
		if(isset($this->request->get['new_id']))
		{
			if(is_numeric($this->request->get['new_id']))
			{
				$NewsInfo = $this->model_news_news->getNewsInfo($this->request->get['new_id']);
				if($NewsInfo!=""&&$NewsInfo!=null&&$NewsInfo!=array())
				{
					$error = 0;
				}
				else 
				{
					$error = 1;
				}
			}
			else 
			{
				$error = 1;
			}
		}
		else 
		{
			$error = 1;
		}
		if($error == 0)
		{		
		
			$Other_News = $this->model_news_news->getOtherNews($this->request->get['new_id']);
			$this->document->keywords = $NewsInfo['meta_key'];
			$this->document->description = $NewsInfo['meta_des'];
			$this->document->title = $NewsInfo['title'];
			$this->data['NewsInfo'] = $NewsInfo;
			$this->data['Other_News'] = $Other_News;
			$this->data['link_news'] = "index.php?route=news/detail";
			$this->data['link_new'] = "index.php?route=news/news";
			$this->children = array(
				'common/column_right',
				'common/footer',
				'common/column_left',
				'common/header'
			);
			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/news/detail.tpl')) {
				$this->template = $this->config->get('config_template') . '/template/news/detail.tpl';
			} else {
				$this->template = 'default/template/news/detail.tpl';
			}
			$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
		}
		else
		{
			$this->redirect("index.php");
		}
	}
}